package cn.larry.demo.domain;

import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.beans.PropertyEditorSupport;
import java.beans.SimpleBeanInfo;

/**
 * 不管用！！！
 * 
 * @author LarryZeal
 *
 */
public class ZooBeanInfo extends SimpleBeanInfo {

	@Override
	public PropertyDescriptor[] getPropertyDescriptors() {
		// property descriptor
		try {
			PropertyDescriptor name = new PropertyDescriptor("name", Zoo.class);
			name.setPropertyEditorClass(new PropertyEditorSupport() {
				public void setAsText(String text) {
					Zoo zoo = new Zoo();
					zoo.setName("通过内部类设置的name:" + text);
					super.setValue(zoo); // 不应该是临时new出来的吧？？？
				}
			}.getClass());

			PropertyDescriptor id = new PropertyDescriptor("id", Zoo.class);
			id.setPropertyEditorClass(new PropertyEditorSupport() {
				public void setAsText(String text) {
					Zoo zoo = new Zoo();
					zoo.setId(Integer.valueOf(text));
					super.setValue(zoo); // 不应该是临时new出来的吧？？？
				}
			}.getClass());

			return new PropertyDescriptor[] { name, id };
			
		} catch (IntrospectionException e) {
			throw new Error(e.toString());
		}

	}
}
